﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.SqlClient;

using Padelcenter.Common;

namespace Padelcenter.DataAccess
{
    #region " SELECT "
    public class Tarjeta_Select : DataAccessBase
    {
        public Tarjeta_Select()
        {
            base.StoredProcedureName = StoredProcedure.Name.Tarjeta_SELECT.ToString();
        }

        public DataSet Get()
        {
            DataSet ds;

            Tarjeta_Select_Prm tarjeta_Select_Prm = new Tarjeta_Select_Prm(this.Tarjeta);
            DataBaseHelper dbhelper = new DataBaseHelper(StoredProcedureName);
            ds = dbhelper.Run(base.ConnectionString, tarjeta_Select_Prm.Parameters);

            return ds;
        }

        private Tarjeta _tarjeta;

        public Tarjeta Tarjeta
        {
            get { return _tarjeta; }
            set { _tarjeta = value; }
        }

    }

    public class Tarjeta_Select_Prm
    {
        public Tarjeta_Select_Prm(Tarjeta tarjeta)
        {
            this.Tarjeta = tarjeta;
            this.BuildParams();
        }

        private void BuildParams()
        {
            SqlParameter[] parameters = 
            {
                new SqlParameter( "@idTarjeta"          , this.Tarjeta.IdTarjeta ),
                new SqlParameter( "@ConFiltroActivo"    , this.Tarjeta.ConFiltroActivo),
                new SqlParameter( "@Activo"             , this.Tarjeta.Activo)
            };

            this.Parameters = parameters;
        }

        private Tarjeta _tarjeta;

        public Tarjeta Tarjeta
        {
            get { return _tarjeta; }
            set { _tarjeta = value; }
        }
        private SqlParameter[] _parameters;

        public SqlParameter[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }
    }
    #endregion

    #region " INSERT "
    public class Tarjeta_Insert : DataAccessBase
    {
        public Tarjeta_Insert()
        {
            base.StoredProcedureName = StoredProcedure.Name.Tarjeta_INSERT.ToString();
        }

        public DataSet Get()
        {
            DataSet ds;

            Tarjeta_Insert_Prm tarjeta_Insert_Prm = new Tarjeta_Insert_Prm(this.Tarjeta);
            DataBaseHelper dbhelper = new DataBaseHelper(StoredProcedureName);
            ds = dbhelper.Run(base.ConnectionString, tarjeta_Insert_Prm.Parameters);

            return ds;
        }

        private Tarjeta _tarjeta;

        public Tarjeta Tarjeta
        {
            get { return _tarjeta; }
            set { _tarjeta = value; }
        }

    }

    public class Tarjeta_Insert_Prm
    {
        public Tarjeta_Insert_Prm(Tarjeta tarjeta)
        {
            this.Tarjeta = tarjeta;
            this.BuildParams();
        }

        private void BuildParams()
        {
            SqlParameter[] parameters = 
            {
                new SqlParameter( "@Descripcion"        , this.Tarjeta.Descripcion ),
                new SqlParameter( "@idMetodoPago"       , this.Tarjeta.IdMetodoPago ),
                new SqlParameter( "@RegEx"              , this.Tarjeta.Regex ),
                new SqlParameter( "@Imagen"             , this.Tarjeta.Imagen),
                new SqlParameter( "@Activo"             , this.Tarjeta.Activo)
            };

            this.Parameters = parameters;
        }

        private Tarjeta _tarjeta;

        public Tarjeta Tarjeta
        {
            get { return _tarjeta; }
            set { _tarjeta = value; }
        }
        private SqlParameter[] _parameters;

        public SqlParameter[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }
    }
    #endregion

    #region " UPDATE "
    public class Tarjeta_Update : DataAccessBase
    {
        public Tarjeta_Update()
        {
            base.StoredProcedureName = StoredProcedure.Name.Tarjeta_UPDATE.ToString();
        }

        public DataSet Get()
        {
            DataSet ds;

            Tarjeta_Update_Prm tarjeta_Update_Prm = new Tarjeta_Update_Prm(this.Tarjeta);
            DataBaseHelper dbhelper = new DataBaseHelper(StoredProcedureName);
            ds = dbhelper.Run(base.ConnectionString, tarjeta_Update_Prm.Parameters);

            return ds;
        }

        private Tarjeta _tarjeta;

        public Tarjeta Tarjeta
        {
            get { return _tarjeta; }
            set { _tarjeta = value; }
        }

    }

    public class Tarjeta_Update_Prm
    {
        public Tarjeta_Update_Prm(Tarjeta tarjeta)
        {
            this.Tarjeta = tarjeta;
            this.BuildParams();
        }

        private void BuildParams()
        {
            SqlParameter[] parameters = 
            {
                new SqlParameter( "@idTarjeta"          , this.Tarjeta.IdTarjeta),
                new SqlParameter( "@Descripcion"        , this.Tarjeta.Descripcion ),
                new SqlParameter( "@idMetodoPago"       , this.Tarjeta.IdMetodoPago ),
                new SqlParameter( "@RegEx"              , this.Tarjeta.Regex ),
                new SqlParameter( "@Imagen"             , this.Tarjeta.Imagen),
                new SqlParameter( "@Activo"             , this.Tarjeta.Activo)
            };

            this.Parameters = parameters;
        }

        private Tarjeta _tarjeta;

        public Tarjeta Tarjeta
        {
            get { return _tarjeta; }
            set { _tarjeta = value; }
        }
        private SqlParameter[] _parameters;

        public SqlParameter[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }
    }
    #endregion
}
